<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">
  <link rel="stylesheet" href="//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.css">
  <link rel="stylesheet" href="/lib/pace/pace-theme-minimal.min.css">
  <script src="/lib/pace/pace.min.js"></script>

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"yoursite.com","root":"/","scheme":"Pisces","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":true},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":true,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":-1,"unescape":false,"preload":true},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"./public/search.xml"};
  </script>

  <meta name="description" content="编辑器相关前端开发的编辑器软件，我首先推荐 VS Code，其次推荐Sublime Text。 有人说 WebStorm 也不错？但真实情况是，自从VS Code 问世之后，用 WebStorm 的人越来越少了。 PS：文件的后缀名不能决定文件格式，只能决定打开文件打开的方式。">
<meta property="og:type" content="article">
<meta property="og:title" content="03-初识HTML">
<meta property="og:url" content="http://yoursite.com/2020/07/07/03-%E5%88%9D%E8%AF%86HTML/index.html">
<meta property="og:site_name" content="GipBaby270&#39;s Blog">
<meta property="og:description" content="编辑器相关前端开发的编辑器软件，我首先推荐 VS Code，其次推荐Sublime Text。 有人说 WebStorm 也不错？但真实情况是，自从VS Code 问世之后，用 WebStorm 的人越来越少了。 PS：文件的后缀名不能决定文件格式，只能决定打开文件打开的方式。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://img.smyhvae.com/20151001_1001.png">
<meta property="og:image" content="http://img.smyhvae.com/20170629_1600.png">
<meta property="og:image" content="http://img.smyhvae.com/20170629_1743.png">
<meta property="og:image" content="http://img.smyhvae.com/2015-10-02-cnblogs_html_39.png">
<meta property="og:image" content="http://img.smyhvae.com/2015-10-02-cnblogs_html_05.gif">
<meta property="og:image" content="http://img.smyhvae.com/20170629_2226.png">
<meta property="og:image" content="http://img.smyhvae.com/20170629_2230.jpg">
<meta property="og:image" content="http://img.smyhvae.com/20170629_2245.jpg">
<meta property="article:published_time" content="2020-07-07T10:24:42.734Z">
<meta property="article:modified_time" content="2020-07-07T11:16:08.558Z">
<meta property="article:author" content="Gip886">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://img.smyhvae.com/20151001_1001.png">

<link rel="canonical" href="http://yoursite.com/2020/07/07/03-%E5%88%9D%E8%AF%86HTML/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>03-初识HTML | GipBaby270's Blog</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    
    <a href="https://github.com/Gip886" target="_blank" rel="noopener" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#64CEAA; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
    
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">GipBaby270's Blog</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">Fighting for BAT!</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2020/07/07/03-%E5%88%9D%E8%AF%86HTML/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/%E5%A4%B4%E5%83%8F.jpg">
      <meta itemprop="name" content="Gip886">
      <meta itemprop="description" content="为了更美好的明天而战">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="GipBaby270's Blog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          03-初识HTML
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2020-07-07 18:24:42 / 修改时间：19:16:08" itemprop="dateCreated datePublished" datetime="2020-07-07T18:24:42+08:00">2020-07-07</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/HTML%E5%9F%BA%E7%A1%80/" itemprop="url" rel="index"><span itemprop="name">HTML基础</span></a>
                </span>
            </span>

          
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span id="busuanzi_value_page_pv"></span>
            </span><br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>9.4k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>9 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h2 id="编辑器相关"><a href="#编辑器相关" class="headerlink" title="编辑器相关"></a>编辑器相关</h2><p>前端开发的编辑器软件，我首先推荐 VS Code，其次推荐Sublime Text。</p>
<p>有人说 WebStorm 也不错？但真实情况是，自从VS Code 问世之后，用 WebStorm 的人越来越少了。</p>
<p>PS：文件的后缀名不能决定文件格式，只能决定打开文件打开的方式。</p>
<a id="more"></a>

<h3 id="VS-Code-的使用"><a href="#VS-Code-的使用" class="headerlink" title="VS Code 的使用"></a>VS Code 的使用</h3><p>详情请移步至：<a href="https://github.com/qianguyihao/Web/blob/master/00-%E5%89%8D%E7%AB%AF%E5%B7%A5%E5%85%B7/01-VS%20Code%E7%9A%84%E4%BD%BF%E7%94%A8.md" target="_blank" rel="noopener">第一次使用VS Code时你应该知道的一切配置</a></p>
<h3 id="Sublime-Text-的使用"><a href="#Sublime-Text-的使用" class="headerlink" title="Sublime Text 的使用"></a>Sublime Text 的使用</h3><p>详情请移步至：<a href="https://github.com/qianguyihao/Mac/blob/master/05-%E5%85%A8%E5%B9%B3%E5%8F%B0%E8%BD%AF%E4%BB%B6/Sublime%20Text%E4%BD%BF%E7%94%A8%E6%8A%80%E5%B7%A7.md" target="_blank" rel="noopener">Sublime Text使用技巧</a></p>
<h2 id="HTML的概述"><a href="#HTML的概述" class="headerlink" title="HTML的概述"></a>HTML的概述</h2><h3 id="HTML的概念"><a href="#HTML的概念" class="headerlink" title="HTML的概念"></a>HTML的概念</h3><p><strong>HTML</strong> 全称为 HyperText Markup Language，译为<font color="#0000ff"><strong>超文本标记语言</strong></font>。</p>
<p>HTML 不是一种编程语言，是一种描述性的<strong>标记语言</strong>。</p>
<p><strong>作用</strong>：HTML是负责描述文档<strong>语义</strong>的语言。</p>
<h3 id="概念：超文本"><a href="#概念：超文本" class="headerlink" title="概念：超文本"></a>概念：超文本</h3><p>所谓的超文本，有两层含义：</p>
<p>（1）图片、音频、视频、动画、多媒体等内容，成为超文本，因为它们超出了文本的限制。</p>
<p>（2）不仅如此，它还可以从一个文件跳转到另一个文件，与世界各地主机的文件进行连接。即：超级链接文本。</p>
<h3 id="概念：标记语言"><a href="#概念：标记语言" class="headerlink" title="概念：标记语言"></a>概念：标记语言</h3><p>HTML 不是一种编程语言，是一种描述性的<strong>标记语言</strong>。这主要有两层含义：</p>
<p>（1）<strong>标记语言是一套标记标签</strong>。比如：标签<code>&lt;a&gt;</code>表示超链接、标签<code>&lt;img&gt;</code>表示图片、标签<code>&lt;h1&gt;</code>表示一级标题等等，它们都是属于 HTML 标签。</p>
<p>说的通俗一点就是：网页是由网页元素组成的，这些元素是由 HTML 标签描述出来，然后通过浏览器解析，就可以显示给用户看了。</p>
<p>（2）编程语言是有编译过程的，而标记语言没有编译过程，HTML标签是直接由浏览器解析执行。</p>
<h3 id="HTML是负责描述文档语义的语言"><a href="#HTML是负责描述文档语义的语言" class="headerlink" title="HTML是负责描述文档语义的语言"></a>HTML是负责描述文档语义的语言</h3><p>HTML 格式的文件是一个纯本文文件（就是用txt文件改名而成），用一些标签来描述语义，这些标签在浏览器页面上是无法直观看到的，所以称之为“超文本标记语言”。</p>
<p>接下来，我们需要学习 HTML 中的很多“标签对儿”，这些“标签对儿”能够给文本不同的语义。</p>
<p>比如，面试的时候问你，<code>&lt;h1&gt;</code> 标签有什么作用？</p>
<ul>
<li>正确答案：给文本增加主标题的语义。</li>
<li>错误答案：给文字加粗、加黑、变大。</li>
</ul>
<p>关乎“语义”的更深刻理解，等接下来我们学习了各种标签，就明白了。</p>
<h2 id="HTML的历史"><a href="#HTML的历史" class="headerlink" title="HTML的历史"></a>HTML的历史</h2><p><img src="http://img.smyhvae.com/20151001_1001.png" alt="html中标签发展趋势"></p>
<p>其中，我们专门来对XHTML做一个介绍。</p>
<p><strong>XHTML介绍：</strong><br>XHTML：Extensible Hypertext Markup Language，可扩展超文本标注语言。<br>XHTML的主要目的是为了<font color="blue"><strong>取代HTML</strong></font>，也可以理解为HTML的升级版。<br>HTML的标记书写很不规范，会造成其它的设备(ipad、手机、电视等)无法正常显示。<br>XHTML与HTML4.0的标记基本上一样。<br>XHTML是<font color="blue"><strong>严格的、纯净的</strong></font>HTML。</p>
<p>我们稍后将对XHTML的编写规范进行介绍。</p>
<h2 id="HTML的专有名词"><a href="#HTML的专有名词" class="headerlink" title="HTML的专有名词"></a>HTML的专有名词</h2><ul>
<li>网页 ：由各种标记组成的一个页面就叫网页。</li>
<li>主页(首页) : 一个网站的起始页面或者导航页面。</li>
<li>标记：  比如<code>&lt;p&gt;</code>称为开始标记 ，<code>&lt;/p&gt;</code>称为结束标记，也叫标签。每个标签都规定好了特殊的含义。</li>
<li>元素：比如<code>&lt;p&gt;内容&lt;/p&gt;</code>称为元素.</li>
<li>属性：给每一个标签所做的辅助信息。</li>
<li>XHTML：符合XML语法标准的HTML。</li>
<li>DHTML：dynamic，动态的。<code>javascript + css + html</code>合起来的页面就是一个 DHTML。</li>
<li>HTTP：超文本传输协议。用来规定客户端浏览器和服务端交互时数据的一个格式。SMTP：邮件传输协议，FTP：文件传输协议。</li>
</ul>
<h2 id="书写第一个-HTML-页面"><a href="#书写第一个-HTML-页面" class="headerlink" title="书写第一个 HTML 页面"></a>书写第一个 HTML 页面</h2><p>我们打开 VS Code 软件，新建一个文件，名叫<code>test.html</code>（注意，文件名是<code>test</code>，后缀名是<code>html</code>），保存到本地。</p>
<p>紧接着，在文件里，输入<code>html:5</code>，然后按一下键盘上的<code>Tab</code>键，就可以自动生成如下内容：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">"en"</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">"UTF-8"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">name</span>=<span class="string">"viewport"</span> <span class="attr">content</span>=<span class="string">"width=device-width, initial-scale=1.0"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">title</span>&gt;</span>Document<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>上面的内容，就是 html 页面的骨架。我们在此基础之上，新增几个标签，完整代码如下：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">"en"</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">"UTF-8"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">name</span>=<span class="string">"viewport"</span> <span class="attr">content</span>=<span class="string">"width=device-width, initial-scale=1.0"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">title</span>&gt;</span>Document<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">h3</span>&gt;</span>我是三级标题<span class="tag">&lt;/<span class="name">h3</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">""</span> <span class="attr">alt</span>=<span class="string">""</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">"https://www.jd.com"</span>&gt;</span>我是超链接，可以点击一下<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>标签写完之后，我们用 chrome 浏览器打开上面这个<code>test.html</code>文件，看看页面效果：</p>
<p>到此，第一个简单的 HTML 页面就写完了。是不是很有成就感？</p>
<h2 id="HTML结构详解"><a href="#HTML结构详解" class="headerlink" title="HTML结构详解"></a>HTML结构详解</h2><p>HTML标签通常是成对出现的（<font color="blue"><strong>双边标记</strong></font>），比如 <code>&lt;div&gt;</code> 和 <code>&lt;/div&gt;</code>；也有少部分单标签（<font color="blue"><strong>单边标记</strong></font>），如：<code>&lt;br /&gt;</code>、<code>&lt;hr /&gt;</code>和<code>&lt;img src=&quot;images/1.jpg&quot; /&gt;</code>等。</p>
<p>属性与标记之间、各属性之间需要以空格隔开。属性值以双引号括起来。</p>
<h4 id="html骨架标签分类"><a href="#html骨架标签分类" class="headerlink" title="html骨架标签分类"></a>html骨架标签分类</h4><table>
<thead>
<tr>
<th>标签名</th>
<th align="center">定义</th>
<th align="left">说明</th>
</tr>
</thead>
<tbody><tr>
<td><code>&lt;html&gt;&lt;/html&gt;</code></td>
<td align="center">HTML标签</td>
<td align="left">页面中最大的标签，我们成为根标签</td>
</tr>
<tr>
<td><code>&lt;head&gt;&lt;/head&gt;</code></td>
<td align="center">文档的头部</td>
<td align="left">注意在head标签中我们必须要设置的标签是title</td>
</tr>
<tr>
<td><code>&lt;titile&gt;&lt;/title&gt;</code></td>
<td align="center">文档的标题</td>
<td align="left">让页面拥有一个属于自己的网页标题</td>
</tr>
<tr>
<td><code>&lt;body&gt;&lt;/body&gt;</code></td>
<td align="center">文档的主体</td>
<td align="left">元素包含文档的所有内容，页面内容 基本都是放到body里面的</td>
</tr>
</tbody></table>
<h3 id="快速生成-html-的骨架"><a href="#快速生成-html-的骨架" class="headerlink" title="快速生成 html 的骨架"></a>快速生成 html 的骨架</h3><p><strong>方式1</strong>：在 VS Code 中新建 html 文件，输入<code>html:5</code>，按 <code>Tab</code>键后，自动生成的代码如下：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">"en"</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">"UTF-8"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">name</span>=<span class="string">"viewport"</span> <span class="attr">content</span>=<span class="string">"width=device-width, initial-scale=1.0"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">http-equiv</span>=<span class="string">"Content-Type"</span> <span class="attr">content</span>=<span class="string">"text/html;charset=UTF-8"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">title</span>&gt;</span>Document<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p><strong>方式2</strong>：在Sublime Text中安装<code>Emmet</code>插件。新建html文件，输入<code>html:5</code>，按<code>Tab</code>键后，自动生成的代码如下：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">"en"</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">"UTF-8"</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">title</span>&gt;</span>Document<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p><strong>方式3</strong>：在Sublime Text中安装<code>Emmet</code>插件。新建html文件，输入<code>html:xt</code>，按<code>Tab</code>键后，自动生成的代码如下：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span> <span class="meta-keyword">PUBLIC</span> <span class="meta-string">"-//W3C//DTD XHTML 1.0 Transitional//EN"</span> <span class="meta-string">"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">xmlns</span>=<span class="string">"http://www.w3.org/1999/xhtml"</span> <span class="attr">xml:lang</span>=<span class="string">"en"</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">meta</span> <span class="attr">http-equiv</span>=<span class="string">"Content-Type"</span> <span class="attr">content</span>=<span class="string">"text/html;charset=UTF-8"</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">title</span>&gt;</span>Document<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>上面的方式2和方式3中，我们会发现，第一行的内容有些不太一样，这就是我们接下来要讲的<strong>文档声明头</strong>。</p>
<h3 id="1、文档声明头"><a href="#1、文档声明头" class="headerlink" title="1、文档声明头"></a>1、文档声明头</h3><p>任何一个标准的HTML页面，第一行一定是一个以<code>&lt;!DOCTYPE ……&gt;</code>开头的语句。这一行，就是文档声明头，即 DocType Declaration，简称DTD。</p>
<p><strong>DTD可告知浏览器文档使用哪种 HTML 或 XHTML 规范</strong>。</p>
<h4 id="HTML4-01有哪些规范呢？"><a href="#HTML4-01有哪些规范呢？" class="headerlink" title="HTML4.01有哪些规范呢？"></a>HTML4.01有哪些规范呢？</h4><p><strong>HTML4.01</strong>这个版本是IE6开始兼容的。<strong>HTML5是IE9开始兼容的</strong>。如今，手机、移动端的网页，就可以使用HTML5了，因为其兼容性更高。</p>
<p>说个题外话，html1 至 html3 是美国军方以及高等研究所用的，并未对外公开。</p>
<p>HTML4.01里面有两大种规范，每大种规范里面又各有3种小规范。所以一共6种规范（见下图）。</p>
<p>HTML4.01里面规定了<strong>普通</strong>和<strong>XHTML</strong>两大种规范。HTML觉得自己有一些规定不严谨，比如，标签是否可以用大写字母呢？<code>&lt;H1&gt;&lt;/H1&gt;</code>所以，HTML就觉得，把一些规范严格的标准，又制定了一个XHTML1.0。在XHTML中的字母X，表示“严格的”。</p>
<p>总结一下，HTML4.01一共有6种DTD。说白了，HTML的第一行语句一共有6种情况：</p>
<p><img src="http://img.smyhvae.com/20170629_1600.png" alt></p>
<p>下面对上图中的三种小规范进行解释：</p>
<p><strong>strict</strong>：</p>
<p>表示“严格的”，这种模式里面的要求更为严格。这种严格体现在哪里？有一些标签不能使用。<br>比如，u标签，就是给一个本文加下划线，但是这和HTML的本质有冲突，因为HTML最好是只负责语义，不要负责样式，而u这个下划线是样式。所以，在strict中是不能使用u标签的。</p>
<p>那怎么给文本增加下划线呢？今后将使用css属性来解决。</p>
<p>XHTML1.0更为严格，因为这个体系本身规定比如标签必须是小写字母、必须严格闭合标签、必须使用引号引起属性等等。</p>
<p><strong>Transitional</strong>：表示“普通的”，这种模式就是没有一些别的规范。</p>
<p><strong>Frameset</strong>：表示“框架”，在框架的页面使用。</p>
<p>在sublime输入的html:xt，x表示XHTML，t表示transitional。</p>
<p>在HTML5中极大的简化了DTD，也就是说HTML5中就没有XHTML了。HTML5的DTD（文档声明头）如下：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;!DOCTYPE html&gt;</span><br></pre></td></tr></table></figure>

<h3 id="2、页面语言-lang"><a href="#2、页面语言-lang" class="headerlink" title="2、页面语言 lang"></a>2、页面语言 <code>lang</code></h3><p>下面这行标签，用于指定页面的语言类型：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">"en"</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>最常见的语言类型有两种：</p>
<ul>
<li><p>en：定义页面语言为英语。</p>
</li>
<li><p>zh-CN：定义页面语言为中文。</p>
</li>
</ul>
<h3 id="2、头标签-head"><a href="#2、头标签-head" class="headerlink" title="2、头标签 head"></a>2、头标签 <code>head</code></h3><h4 id="html5-的比较完整的骨架："><a href="#html5-的比较完整的骨架：" class="headerlink" title="html5 的比较完整的骨架："></a>html5 的比较完整的骨架：</h4><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">"en"</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">"UTF-8"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">name</span>=<span class="string">"viewport"</span> <span class="attr">content</span>=<span class="string">"width=device-width, initial-scale=1.0"</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">meta</span> <span class="attr">http-equiv</span>=<span class="string">"Content-Type"</span> <span class="attr">content</span>=<span class="string">"text/html;charset=UTF-8"</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">meta</span> <span class="attr">name</span>=<span class="string">"Author"</span> <span class="attr">content</span>=<span class="string">""</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">name</span>=<span class="string">"Keywords"</span> <span class="attr">content</span>=<span class="string">"厉害很厉害"</span> /&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">name</span>=<span class="string">"Description"</span> <span class="attr">content</span>=<span class="string">"网易是中国领先的互联网技术公司，为用户提供免费邮箱、游戏、搜索引擎服务，开设新闻、娱乐、体育等30多个内容频道，及博客、视频、论坛等互动交流，网聚人的力量。"</span> /&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">title</span>&gt;</span>Document<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>面试题：</p>
<ul>
<li>问：网页的head标签里面，表示的是页面的配置，有什么配置？</li>
<li>答：字符集、关键词、页面描述、页面标题、IE适配、视口、iPhone小图标等等。</li>
</ul>
<p>头标签内部的常见标签如下：</p>
<ul>
<li><code>&lt;title&gt;</code>：指定整个网页的标题，在浏览器最上方显示。</li>
<li><code>&lt;base&gt;</code>：为页面上的所有链接规定默认地址或默认目标。</li>
<li><code>&lt;meta&gt;</code>：提供有关页面的基本信息</li>
<li><code>&lt;body&gt;</code>：用于定义HTML文档所要显示的内容，也称为主体标签。我们所写的代码必须放在此标签內。</li>
<li><code>&lt;link&gt;</code>：定义文档与外部资源的关系。</li>
</ul>
<p><strong>meta 标签</strong>：</p>
<p>meta表示“元”。“元”配置，就是表示基本的配置项目。</p>
<p>常见的几种 meta 标签如下：</p>
<p>（1）字符集 charset：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">http-equiv</span>=<span class="string">"Content-Type"</span> <span class="attr">content</span>=<span class="string">"text/html;charset=UTF-8"</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>字符集用meta标签中的<code>charset</code>定义，charset就是charactor set（即“字符集”），即<strong>网页的编码方式</strong>。</p>
<p><strong>字符集</strong>(Character set)是多个字符的集合。计算机要准确的处理各种字符集文字，需要进行字符编码，以便计算机能够识别和存储各种文字。</p>
<p>上面这行代码非常关键， 是必须要写的代码，否则可能导致乱码。比如你保存的时候，meta写的和声明的不匹配，那么浏览器就是乱码。</p>
<p>utf-8是目前最常用的字符集编码方式，常用的字符集编码方式还有gbk和gb2312等。关于“编码方式”，我们在下一段会详细介绍。</p>
<p>（2）视口 viewport：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">name</span>=<span class="string">"viewport"</span> <span class="attr">content</span>=<span class="string">"width=device-width, initial-scale=1.0"</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p><code>width=device-width</code> ：表示视口宽度等于屏幕宽度。</p>
<p>viewport 这个知识点，初学者还比较难理解，以后学 Web 移动端的时候会用到。</p>
<p>（3）定义“关键词”：</p>
<p>举例如下：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">name</span>=<span class="string">"Keywords"</span> <span class="attr">content</span>=<span class="string">"网易,邮箱,游戏,新闻,体育,娱乐,女性,亚运,论坛,短信"</span> /&gt;</span></span><br></pre></td></tr></table></figure>

<p>这些关键词，就是告诉搜索引擎，这个网页是干嘛的，能够提高搜索命中率。让别人能够找到你，搜索到你。</p>
<p>（4）定义“页面描述”：</p>
<p>meta除了可以设置字符集，还可以设置关键字和页面描述。</p>
<p>只要设置Description页面描述，那么百度搜索结果，就能够显示这些语句，这个技术叫做<strong>SEO</strong>（search engine optimization，搜索引擎优化）。</p>
<p>设置页面描述的举例：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">name</span>=<span class="string">"Description"</span> <span class="attr">content</span>=<span class="string">"网易是中国领先的互联网技术公司，为用户提供免费邮箱、游戏、搜索引擎服务，开设新闻、娱乐、体育等30多个内容频道，及博客、视频、论坛等互动交流，网聚人的力量。"</span> /&gt;</span></span><br></pre></td></tr></table></figure>

<p>效果如下：</p>
<p><img src="http://img.smyhvae.com/20170629_1743.png" alt></p>
<p>上面的几种<code>&lt;meta&gt;</code>标签都不用记，但是另外还有一个<code>&lt;meta&gt;</code>标签是需要记住的：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">http-equiv</span>=<span class="string">"refresh"</span> <span class="attr">content</span>=<span class="string">"3;http://www.baidu.com"</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p>上面这个标签的意思是说，3秒之后，自动跳转到百度页面。</p>
<p><strong>title 标签</strong>:</p>
<p>用于设置网页标题：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">title</span>&gt;</span>网页的标题<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p>title标签也是有助于SEO搜索引擎优化的。</p>
<p><strong>base标签</strong>：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">base</span> <span class="attr">href</span>=<span class="string">"/"</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>base 标签用于指定基础的路径。指定之后，所有的 a 链接都是以这个路径为基准。</p>
<h3 id="3、-lt-body-gt-标签"><a href="#3、-lt-body-gt-标签" class="headerlink" title="3、&lt;body&gt;标签"></a>3、<code>&lt;body&gt;</code>标签</h3><p><code>&lt;body&gt;</code>标签的属性有：</p>
<ul>
<li><code>bgcolor</code>：设置整个网页的背景颜色。</li>
<li><code>background</code>：设置整个网页的背景图片。</li>
<li><code>text</code>：设置网页中的文本颜色。</li>
<li><code>leftmargin</code>：网页的左边距。IE浏览器默认是8个像素。</li>
<li><code>topmargin</code>：网页的上边距。</li>
<li><code>rightmargin</code>：网页的右边距。</li>
<li><code>bottommargin</code>：网页的下边距。</li>
</ul>
<p><code>&lt;body&gt;</code>标签另外还有一些属性，这里用个例子来解释：</p>
<p><img src="http://img.smyhvae.com/2015-10-02-cnblogs_html_39.png" alt></p>
<p>上方代码中，当我们对<code>点我点我</code>这几个字使用超链时，<code>link</code>属性表示默认显示的颜色、<code>alink</code>属性表示鼠标点击但是还没有松开时的颜色、<code>vlink</code>属性表示点击完成之后显示的颜色。效果如下：</p>
<p><img src="http://img.smyhvae.com/2015-10-02-cnblogs_html_05.gif" alt></p>
<h2 id="计算机编码介绍"><a href="#计算机编码介绍" class="headerlink" title="计算机编码介绍"></a>计算机编码介绍</h2><p>计算机，不能直接存储文字，存储的是编码。</p>
<p>计算机只能处理二进制的数据，其它数据，比如：0-9、a-z、A-Z，这些字符，我们可以定义一套规则来表示。假如：A用110表示，B用111表示等。</p>
<p><strong>ASCII码：</strong><br>美国发布的，用1个字节(8位二进制)来表示一个字符，共可以表示2^8=256个字符。<br>    美国的国家语言是英语，只要能表示0-9、a-z、A-Z、特殊符号。</p>
<p><strong>ANSI编码：</strong><br><strong>每个国家为了显示本国的语言，都对ASCII码进行了扩展</strong>。用2个字节(16位二进制)来表示一个汉字，共可以表示2^16＝65536个汉字。例如：<br>中国的ANSI编码是GB2312编码(简体)，对6763汉字进行编码，含600多特殊字符。另外还有GBK(简体)。<br>日本的ANSI编码是JIS编码。<br>台湾的ANSI编码是BIG5编码（繁体）。</p>
<p><strong>GBK：</strong><br>对GB2312进行了扩展，用来显示罕见的、古汉语的汉字。现在已经收录了2.1万左右。并提供了1890个汉字码位。K的含义就是“扩展”。</p>
<p><strong>Unicode编码(统一编码)：</strong><br>用4个字节(32位二进制)来表示一个字符，想法不错，但效率太低。例如，字母A用ASCII表示的话一个字节就够，可用Unicode编码的话，得用4个字节表示，造成了空间的极大浪费。A的Unicode编码是0000 0000 0000 0000 0000 0000 0100 0000</p>
<p><strong>UTF-8(Unicode Transform Format)编码：</strong><br>根据字符的不同，选择其编码的长度。比如：一个字符A用1个字节表示，一个汉字用2个字节表示。</p>
<p>毫无疑问，开发中，都用<strong>UTF-8</strong>编码吧，准没错。</p>
<p><strong>中文能够使用的字符集两种：</strong></p>
<ul>
<li><p>第一种：UTF-8。UTF-8是国际通用字库，里面涵盖了所有地球上所有人类的语言文字，比如阿拉伯文、汉语、鸟语……</p>
</li>
<li><p>第二种：GBK（对GB2312进行了扩展）。gb2312 是国标，是中国的字库，里面<strong>仅</strong>涵盖了汉字和一些常用外文，比如日文片假名，和常见的符号。</p>
</li>
</ul>
<p>字库规模：  UTF-8（字很全） &gt; gb2312（只有汉字）</p>
<p><strong>重点1：避免乱码</strong></p>
<p>我们用meta标签声明的当前这个html文档的字库，一定要和保存的文件编码类型一样，否则乱码（重点）。</p>
<p>拿 sublime编辑器举例，当我们不设置的时候，sublime默认类型就是UTF-8。而一旦更改为gb2312的时候，就一定要记得设置一下sublime的保存类型： <code>文件→ set File Encoding to → Chinese Simplified(GBK)</code>。VS Code 的道理一样。</p>
<p><strong>重点2：UTF-8和gb2312的比较</strong></p>
<p>保存大小：UTF-8（更臃肿、加载更慢） &gt; gb2312 （更小巧，加载更快）</p>
<p>总结：</p>
<ul>
<li>UTF-8：字多，有各种国家的语言，但是保存尺寸大，文件臃肿；</li>
<li>gb2312：字少，只用中文和少数外语和符号，但是尺寸小，文件小巧。</li>
</ul>
<p>列出2个使用情形：</p>
<p>1） 你们公司是做日本动漫的，经常出现一些日语动漫的名字，网页要使用UTF-8。如果用gb2312将无法显示日语。<br>2） 你们公司就是中文网页，极度的追求网页的显示速度，要使用gb2312。如果使用UTF-8将每个汉字多一个byte，所以5000个汉字，多5kb。</p>
<p>我们亲测：</p>
<ul>
<li>qq网、网易、搜狐都是使用gb2312。这些公司，都追求显示速度。</li>
<li>新华网藏语频道，使用的是UTF-8，保证字符集的数量。</li>
</ul>
<p>我们是怎么查看网页的编码方式的呢？在浏览器中打开网页，右键，选择“查看网页源代码”，找到meta标签中的charset属性即可。</p>
<p>那么，我们为什么可以查看网页的源代码呢？因为这个打开的html网页已经存到我的临时文件夹里了，临时文件夹里的html是纯文本文件，纯文本文件自然可以查看网页的源代码。</p>
<h2 id="HTML的规范"><a href="#HTML的规范" class="headerlink" title="HTML的规范"></a>HTML的规范</h2><ul>
<li>HTML不区分大小写，但HTML的标签名、类名、标签属性、大部分属性值建议统一用小写。</li>
<li>HTML页面的后缀名是html或者htm(有一些系统不支持后缀名长度超过3个字符，比如dos系统)</li>
</ul>
<h3 id="1、编写XHTML的规范："><a href="#1、编写XHTML的规范：" class="headerlink" title="1、编写XHTML的规范："></a>1、编写XHTML的规范：</h3><p>（1）所有标记元素都要正确的嵌套，不能交叉嵌套。正确写法举例：<code>&lt;h1&gt;&lt;font&gt;&lt;/font&gt;&lt;/h1&gt;</code></p>
<p>（2）所有的标记都必须小写。</p>
<p>（3）所有的标签都必须闭合。</p>
<ul>
<li><p>双标签：<code>&lt;span&gt;&lt;/span&gt;</code></p>
</li>
<li><p>单标签：<code>&lt;br&gt;</code> 建议写成 <code>&lt;br /&gt;</code>   <code>&lt;hr&gt;</code> 建议转成 <code>&lt;hr /&gt;</code>，还有<code>&lt;img src=“URL” /&gt;</code></p>
</li>
</ul>
<p>（4）所有的属性值必须加引号。<code>&lt;font  color=&quot;red&quot;&gt;&lt;/font&gt;</code></p>
<p>（5）所有的属性必须有值。<code>&lt;hr noshade=&quot;noshade&quot;&gt;</code>、<code>&lt;input  type=&quot;radio&quot; checked=&quot;checked&quot; /&gt;</code></p>
<p>（6）XHTML文档开头必须要有DTD文档类型定义。</p>
<h3 id="2、HTML的基本语法特性"><a href="#2、HTML的基本语法特性" class="headerlink" title="2、HTML的基本语法特性"></a>2、HTML的基本语法特性</h3><h4 id="（1）HTML对换行不敏感，对tab不敏感"><a href="#（1）HTML对换行不敏感，对tab不敏感" class="headerlink" title="（1）HTML对换行不敏感，对tab不敏感"></a>（1）HTML对换行不敏感，对tab不敏感</h4><p>HTML只在乎标签的嵌套结构，嵌套的关系。谁嵌套了谁，谁被谁嵌套了，和换行、tab无关。换不换行、tab不tab，都不影响页面的结构。</p>
<p>也就是说，HTML不是依靠缩进来表示嵌套的，而是看标签的嵌套关系。但是，我们发现有良好的缩进，代码更易读。建议大家都正确缩进标签。</p>
<p>百度为了追求极致的显示速度，所有HTML标签都没有换行、都没有缩进（tab），HTML和换不换行无关，标签的层次依然清晰，只不过程序员不可读了。如下图所示：</p>
<p><img src="http://img.smyhvae.com/20170629_2226.png" alt></p>
<h4 id="（2）空白折叠现象"><a href="#（2）空白折叠现象" class="headerlink" title="（2）空白折叠现象"></a>（2）空白折叠现象</h4><p>HTML中所有的<strong>文字之间</strong>，如果有空格、换行、tab都将被折叠为一个空格显示。</p>
<p>举例如下：</p>
<p><img src="http://img.smyhvae.com/20170629_2230.jpg" alt></p>
<h4 id="（3）标签要严格封闭"><a href="#（3）标签要严格封闭" class="headerlink" title="（3）标签要严格封闭"></a>（3）标签要严格封闭</h4><p>标签不封闭的结果是灾难性的。</p>
<p>标签不封闭的举例如下：</p>
<p><img src="http://img.smyhvae.com/20170629_2245.jpg" alt></p>

    </div>

    
    
    
        <div class="reward-container">
  <div>坚持原创技术分享，您的支持将鼓励我继续分享！</div>
  <button onclick="var qr = document.getElementById('qr'); qr.style.display = (qr.style.display === 'none') ? 'block' : 'none';">
    打赏
  </button>
  <div id="qr" style="display: none;">
      
      <div style="display: inline-block;">
        <img src="/images/wechatpay.png" alt="Gip886 微信支付">
        <p>微信支付</p>
      </div>

  </div>
</div>


      <footer class="post-footer">

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2020/07/07/07-html%E6%A0%87%E7%AD%BE%E5%9B%BE%E6%96%87%E8%AF%A6%E8%A7%A3%EF%BC%88%E4%BA%8C%EF%BC%89/" rel="prev" title="07-html标签图文详解（二）">
      <i class="fa fa-chevron-left"></i> 07-html标签图文详解（二）
    </a></div>
      <div class="post-nav-item">
    <a href="/2020/07/07/04-HTML%E6%A0%87%E7%AD%BE%EF%BC%9A%E6%8E%92%E7%89%88%E6%A0%87%E7%AD%BE/" rel="next" title="04-HTML标签：排版标签">
      04-HTML标签：排版标签 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#编辑器相关"><span class="nav-number">1.</span> <span class="nav-text">编辑器相关</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#VS-Code-的使用"><span class="nav-number">1.1.</span> <span class="nav-text">VS Code 的使用</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Sublime-Text-的使用"><span class="nav-number">1.2.</span> <span class="nav-text">Sublime Text 的使用</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#HTML的概述"><span class="nav-number">2.</span> <span class="nav-text">HTML的概述</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#HTML的概念"><span class="nav-number">2.1.</span> <span class="nav-text">HTML的概念</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#概念：超文本"><span class="nav-number">2.2.</span> <span class="nav-text">概念：超文本</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#概念：标记语言"><span class="nav-number">2.3.</span> <span class="nav-text">概念：标记语言</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#HTML是负责描述文档语义的语言"><span class="nav-number">2.4.</span> <span class="nav-text">HTML是负责描述文档语义的语言</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#HTML的历史"><span class="nav-number">3.</span> <span class="nav-text">HTML的历史</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#HTML的专有名词"><span class="nav-number">4.</span> <span class="nav-text">HTML的专有名词</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#书写第一个-HTML-页面"><span class="nav-number">5.</span> <span class="nav-text">书写第一个 HTML 页面</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#HTML结构详解"><span class="nav-number">6.</span> <span class="nav-text">HTML结构详解</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#html骨架标签分类"><span class="nav-number">6.0.1.</span> <span class="nav-text">html骨架标签分类</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#快速生成-html-的骨架"><span class="nav-number">6.1.</span> <span class="nav-text">快速生成 html 的骨架</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1、文档声明头"><span class="nav-number">6.2.</span> <span class="nav-text">1、文档声明头</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#HTML4-01有哪些规范呢？"><span class="nav-number">6.2.1.</span> <span class="nav-text">HTML4.01有哪些规范呢？</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2、页面语言-lang"><span class="nav-number">6.3.</span> <span class="nav-text">2、页面语言 lang</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2、头标签-head"><span class="nav-number">6.4.</span> <span class="nav-text">2、头标签 head</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#html5-的比较完整的骨架："><span class="nav-number">6.4.1.</span> <span class="nav-text">html5 的比较完整的骨架：</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3、-lt-body-gt-标签"><span class="nav-number">6.5.</span> <span class="nav-text">3、&lt;body&gt;标签</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#计算机编码介绍"><span class="nav-number">7.</span> <span class="nav-text">计算机编码介绍</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#HTML的规范"><span class="nav-number">8.</span> <span class="nav-text">HTML的规范</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1、编写XHTML的规范："><span class="nav-number">8.1.</span> <span class="nav-text">1、编写XHTML的规范：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2、HTML的基本语法特性"><span class="nav-number">8.2.</span> <span class="nav-text">2、HTML的基本语法特性</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#（1）HTML对换行不敏感，对tab不敏感"><span class="nav-number">8.2.1.</span> <span class="nav-text">（1）HTML对换行不敏感，对tab不敏感</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#（2）空白折叠现象"><span class="nav-number">8.2.2.</span> <span class="nav-text">（2）空白折叠现象</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#（3）标签要严格封闭"><span class="nav-number">8.2.3.</span> <span class="nav-text">（3）标签要严格封闭</span></a></li></ol></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="Gip886"
      src="/images/%E5%A4%B4%E5%83%8F.jpg">
  <p class="site-author-name" itemprop="name">Gip886</p>
  <div class="site-description" itemprop="description">为了更美好的明天而战</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">29</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">7</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/Gip886" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;Gip886" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>



      </div>
        <iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=300 height=86 src="//music.163.com/outchain/player?type=2&id=492390949&auto=1&height=66"></iframe>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Gip886</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-area"></i>
    </span>
      <span class="post-meta-item-text">站点总字数：</span>
    <span title="站点总字数">153k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span class="post-meta-item-text">站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">2:19</span>
</div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script size="300" alpha="0.6" zIndex="-1" src="/lib/canvas-ribbon/canvas-ribbon.js"></script>
  <script src="/lib/anime.min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js"></script>
  <script src="//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>


  <script defer src="/lib/three/three.min.js"></script>
    <script defer src="/lib/three/canvas_lines.min.js"></script>


  




  
<script src="/js/local-search.js"></script>













  

  

<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","model":{"jsonPath":"/live2dw/assets/koharu.model.json"},"display":{"position":"right","width":150,"height":300},"mobile":{"show":true},"log":false,"tagMode":false});</script></body>
<!-- 页面点击小红心 -->
<script type="text/javascript" src="/js/clicklove.js"></script>
</html>

